package com.gdones.wms.bus.classification.controller;


import com.gdones.common.core.annotations.MySysLog;
import com.gdones.common.core.annotations.MySysLogOpration;
import com.gdones.common.core.dto.MyPageBand;
import com.gdones.common.core.dto.MyResult;
import com.gdones.wms.bus.classification.dto.WmsClassification;
import com.gdones.wms.bus.classification.dto.WmsClassificationModel;
import com.gdones.wms.bus.classification.service.IWmsClassificationModelService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 物资分类下的物资型号 前端控制器
 * </p>
 *
 * @author GaoJingBo
 * @since 2023-05-04
 */
@RestController
@RequestMapping("/classification/model")
@Slf4j
@Api(tags = "物资型号管理")
public class WmsClassificationModelController {

    @Resource(name = "wmsClassificationModelServiceImpl")
    private IWmsClassificationModelService wmsClassificationModelService;

    @GetMapping("/pages")
    @ApiOperation("物资型号列表查询")
    @MySysLog(modelName="物资型号",methodDesc = "物资型号列表查询",methodType = MySysLogOpration.GET)
    public MyResult pages(WmsClassificationModel classificationModel, MyPageBand pageBand){
        log.info("物资型号-物资型号列表查询");

        MyResult result = new MyResult();

        try {
            result = wmsClassificationModelService.pages(classificationModel,pageBand);
        }catch (Exception e){
            e.printStackTrace();
            result.setCode("9999");
            result.setMsg("物资型号-物资型号列表查询-系统异常");
        }

        return result;
    }

    @GetMapping("/list")
    @ApiOperation("物资型号列表查询(不分页)")
    @MySysLog(modelName="物资型号",methodDesc = "物资型号列表查询(不分页)",methodType = MySysLogOpration.GET)
    public MyResult list(WmsClassificationModel classificationModel){
        log.info("物资型号-物资型号列表查询(不分页)");

        MyResult result = new MyResult();

        try {
            result = wmsClassificationModelService.myList(classificationModel);
        }catch (Exception e){
            e.printStackTrace();
            result.setCode("9999");
            result.setMsg("物资型号-物资型号列表查询(不分页)-系统异常");
        }

        return result;
    }

    @PostMapping("/add")
    @ApiOperation("物资型号添加")
    @MySysLog(modelName="物资型号",methodDesc = "添加",methodType = MySysLogOpration.POST)
    public MyResult add(@RequestBody WmsClassificationModel classificationModel){
        log.info("物资型号-添加");

        MyResult result = new MyResult();

        try {
            result = wmsClassificationModelService.add(classificationModel);
        }catch (Exception e){
            e.printStackTrace();
            result.setCode("9999");
            result.setMsg("物资分类-物资分类添加-系统异常");
        }

        return result;
    }

    @PutMapping("/update")
    @ApiOperation("物资型号添加")
    @MySysLog(modelName="物资型号",methodDesc = "修改",methodType = MySysLogOpration.PUT)
    public MyResult update(@RequestBody WmsClassificationModel classificationModel){
        log.info("物资型号-修改");

        MyResult result = new MyResult();

        try {
            result = wmsClassificationModelService.update(classificationModel);
        }catch (Exception e){
            e.printStackTrace();
            result.setCode("9999");
            result.setMsg("物资型号-修改-系统异常");
        }

        return result;
    }

    @DeleteMapping("/deletes")
    @ApiOperation("物资型号-删除")
    @MySysLog(modelName="物资型号",methodDesc = "删除",methodType = MySysLogOpration.DELETE)
    public MyResult deletes(String ids){
        log.info("物资型号-删除");

        MyResult result = new MyResult();

        try {
            result = wmsClassificationModelService.deletes(ids);
        }catch (Exception e){
            e.printStackTrace();
            result.setCode("9999");
            result.setMsg("物资型号-删除-系统异常");
        }

        return result;
    }

}
